A variable length code is a code system for generating a code having a short average code length by respectively assigning a code having a short code length to a frequently occurring symbol and a code having a long code length to a rarely occurring symbol on the basis of the frequencies of occurrence of symbols. By using variable length codes, therefore, the amount of data can be greatly compressed as compared with the data before encoding. For this reason, variable length codes are widely used as codes for information compression.
In a video encoding system as well, variable length codes are used for a general standard scheme such as MPEG1, MPEG2, H.261, or H.263.
A general problem associated with variable length codes is that when an error is mixed in encoded data due to a channel error or the like, the encoded data mixed with the error cannot be properly decoded by a decoding apparatus owing to the influences of the error. In order to prevent this problem, when an error can occur in a transmission channel, a method of preventing the propagation of an error by inserting sync codes in data at given intervals is generally used. A bit pattern that does not appear by any combination of variable length codes is assigned to a sync code. According to this method, even if an error occurs in encoded data and the data cannot be decoded, the propagation of the error can be prevented by resuming decoding upon detection of the next sync code, thereby continuing the decoding.
Even with the use of sync codes, however, decoding cannot be performed for encoded data between the position where an error has occurred and decoding cannot be performed and the position where the next sync code is detected.
A variable-length decoding/encoding apparatus which can reduce the portion, which cannot be decoded, by using variable length codes that can be decoded bidirectionally, i.e, forward and backward and performing backward decoding upon detection of a next sync code, has been proposed in the patent application (Japanese Patent Application Nos. 7-260383 and 9-81614) filed by the present applicant.
Even with such a variable-length encoding/decoding apparatus, an error in encoded data can be detected only when, for example, a bit pattern that is not used as a code word of a variable-length code appears. For this reason, in some case, an error is detected at a succeeding position considerably away from the position where the error is actually mixed in the data. This is because a bit pattern that is not used as a code word of a variable length code does not always appear at the position where the error is actually mixed in the data, and decode processing is continuously performed as long as a corresponding portion is present in the bit patterns used as the code words of the variable length code. As a result, an incorrect word code is erroneously decoded as a correct code word.
Various methods have been examined as counter-measures against channel errors in a video encoding/decoding apparatus. For example, several methods as countermeasures against channel errors are disclosed in a literature (Hideo Kuroda, “Image Coding Technique”, Shokodo, 1996). Of these methods, error concealment is introduced as a technique used on the decoder side. Error concealment is a technique of minimizing the influences of an error on a frame by using motion vectors on the peripheral portion of the frame upon occurrence of a loss of encoded data.
If, however, an incorrect code word is decoded as a correct code word, a technique of minimizing the influences of an error, such as the above error concealment, cannot be used. As a result, the frame is affected by the error.
The influences of an error in the INTRA mode (intraframe encoding mode) are larger than those in the INTER mode (interframe encoding mode), and a block in unnatural color appears on a frame.
As described above, in the conventional variable-length decoding apparatus, when a variable length code is decoded, an incorrect code word may be decoded as a correct word. If, therefore, this apparatus is applied to decoding of a variable length encoded video signal, a frame is affected by an error.
It is an object of the present invention to provide a variable-length decoding apparatus and a decoding method which can decrease the possibility that an incorrect code word is erroneously decoded as a correct word, and can realize sufficient resistance to errors.